package com.xigua.juc;

/**
 * @author LiRongHua
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: ${todo}
 * @date 2021/8/2515:35
 */
public class DoubleCheckLockSingleton {

    private static volatile DoubleCheckLockSingleton instance = null;

    private DoubleCheckLockSingleton(){
        System.out.println("====");
    }

    public static DoubleCheckLockSingleton getInstance(){
        if (instance == null){
            synchronized (DoubleCheckLockSingleton.class){
                if (instance == null){
                    instance = new DoubleCheckLockSingleton();
                }
            }
        }
        return instance;
    }

    public static void main(String[] args) {
        DoubleCheckLockSingleton instance = DoubleCheckLockSingleton.getInstance();
        DoubleCheckLockSingleton instance2 = DoubleCheckLockSingleton.getInstance();
    }

}
